<!DOCTYPE html><html lang="zh-Hans" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>DreamcatcherDENG 的个人博客</title><meta name="author" content="dreamcatcherdeng"><meta name="copyright" content="dreamcatcherdeng"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="referrer" content="no-referrer"><meta property="og:type" content="website">
<meta property="og:title" content="DreamcatcherDENG 的个人博客">
<meta property="og:url" content="https://dreamcatcherdeng.github.io/personal-blog/index.html">
<meta property="og:site_name" content="DreamcatcherDENG 的个人博客">
<meta property="og:locale">
<meta property="og:image" content="https://n.sinaimg.cn/sinakd10100/452/w1080h972/20200416/93dc-iskepxs3894040.jpg">
<meta property="article:author" content="dreamcatcherdeng">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://n.sinaimg.cn/sinakd10100/452/w1080h972/20200416/93dc-iskepxs3894040.jpg"><link rel="shortcut icon" href="/personal-blog/img/favicon.png"><link rel="canonical" href="https://dreamcatcherdeng.github.io/personal-blog/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/personal-blog/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/personal-blog/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"We didn't find any results for the search: ${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: 'Copy successfully',
    error: 'Copy error',
    noSupport: 'The browser does not support'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: 'Just',
    min: 'minutes ago',
    hour: 'hours ago',
    day: 'days ago',
    month: 'months ago'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'DreamcatcherDENG 的个人博客',
  isPost: false,
  isHome: true,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2022-07-17 00:42:18'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><!-- hexo injector head_end start -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css">

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hexo-math@4.0.0/dist/style.css">
<!-- hexo injector head_end end --><meta name="generator" content="Hexo 5.4.2"><link rel="alternate" href="/personal-blog/atom.xml" title="DreamcatcherDENG 的个人博客" type="application/atom+xml">
</head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://n.sinaimg.cn/sinakd10100/452/w1080h972/20200416/93dc-iskepxs3894040.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data is-center"><div class="data-item"><a href="/personal-blog/archives/"><div class="headline">Articles</div><div class="length-num">34</div></a></div><div class="data-item"><a href="/personal-blog/tags/"><div class="headline">Tags</div><div class="length-num">0</div></a></div><div class="data-item"><a href="/personal-blog/categories/"><div class="headline">Categories</div><div class="length-num">35</div></a></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/personal-blog/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/personal-blog/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/personal-blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div><div class="menus_item"><a class="site-page" href="/personal-blog/about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div></div></div><div class="page" id="body-wrap"><header class="full_page" id="page-header" style="background-image: url('https://gitee.com/DreamcatcherDENG/drawing-bed/raw/master/img/wallhaven-72rd8e.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/personal-blog/">DreamcatcherDENG 的个人博客</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> Search</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/personal-blog/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/personal-blog/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/personal-blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div><div class="menus_item"><a class="site-page" href="/personal-blog/about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="site-info"><h1 id="site-title">DreamcatcherDENG 的个人博客</h1><div id="site_social_icons"><a class="social-icon" href="https://github.com/DreamcatcherDENG" target="_blank" title="Github"><i class="fab fa-github"></i></a></div></div><div id="scroll-down"><i class="fas fa-angle-down scroll-down-effects"></i></div></header><main class="layout" id="content-inner"><div class="recent-posts" id="recent-posts"><div class="recent-post-item"><div class="post_cover left"><a href="/personal-blog/2022/07/13/RegularExpression/" title="正则表达式"><img class="post_bg" src="https://gitee.com/DreamcatcherDENG/drawing-bed/raw/master/img/romance-2258599_960_720.jpg" onerror="this.onerror=null;this.src='/personal-blog/img/404.jpg'" alt="正则表达式"></a></div><div class="recent-post-info"><a class="article-title" href="/personal-blog/2022/07/13/RegularExpression/" title="正则表达式">正则表达式</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-07-13T09:38:01.002Z" title="Created 2022-07-13 17:38:01">2022-07-13</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/personal-blog/categories/Java/">Java</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/personal-blog/categories/Java/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/">正则表达式</a></span></div><div class="content">
本文介绍了正则表达式的常见知识点，并列举了正则表达式的方法。本文的知识点来自韩顺平的正则表达式讲解。


视频地址
正则表达式的概念使用单一的字符串模式描述或匹配一些列具有相同规则的字符串的一种公式。
正则表达式的使用转义符
注：在java的正则表达式中，转义符是\\,即两个\相当于其他语言的一个\


匹配一个转义符

原字符串使用两个反斜杠表示一个反斜杠，模式串使用四个反斜杠匹配一个反斜杠
12str = &quot;hello\\world&quot;；pattern = &quot;\\\\&quot;;//前两个\表示一个\，即正常的转义符，后两个\表示一个\，后面的\被前面的\转义使其不再具有转义的功能，从而正常表达为\，所以需要四个\表示一个\


匹配两个转义符
原字符串使用四个反斜杠表示两个反斜杠，模式字符串使用八个反斜杠表示两个反斜杠
通常需要被转义的字符有：
.*+()$/\?[]^&#123;&#125;


字符匹配符字符匹配符即元字符，用于匹配一般字符的字符




符号
符号解释
示例
示例解释




[]
匹配中括号内的任意一个字符
[abcde]
 ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/personal-blog/2022/07/13/Nodejs/" title="JavaScript and NodeJs"><img class="post_bg" src="https://gitee.com/DreamcatcherDENG/drawing-bed/raw/master/img/wallhaven-0qxx54.jpg" onerror="this.onerror=null;this.src='/personal-blog/img/404.jpg'" alt="JavaScript and NodeJs"></a></div><div class="recent-post-info"><a class="article-title" href="/personal-blog/2022/07/13/Nodejs/" title="JavaScript and NodeJs">JavaScript and NodeJs</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-07-13T09:38:00.960Z" title="Created 2022-07-13 17:38:00">2022-07-13</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/personal-blog/categories/JavaScript/">JavaScript</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/personal-blog/categories/JavaScript/ES6/">ES6</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/personal-blog/categories/JavaScript/Node/">Node</a></span></div><div class="content">
本文介绍了Node.js的安装与配置方法,javascript的部分新增语法特性,收录了javascript和Node.js学习网站和前端框架网站,收集了学习过程中遇到的问题


链接
阮一峰Javascript标准参考教程 

前端工坊 javascript和node.js框架库

MDN Web Docs javascript 权威教程

Element-ui 前端Ui组件库

Bootstrap 前端Ui组件库

W3C中文官网

Node.js中文社区


Node.js安装与配置安装从官网下载Node.js node官网设置安装路径一直点击next就可以了
配置默认情况下，npm下载的包都存放在C:\Users\YOU\AppData\Roaming\npm\node_modules目录的下缓存放在C:\Users\YOU\AppData\Local\npm-cache下,可使用npm config list -l查看详情信息
更改默认缓存和包的位置，设置为自定义路径123npm config set prefix &quot;...\NodeJs\npm_gloabal_ ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/personal-blog/2022/07/13/MySQL/" title="MySQL"><img class="post_bg" src="https://gitee.com/DreamcatcherDENG/drawing-bed/raw/master/img/wallhaven-e7ek7k.jpg" onerror="this.onerror=null;this.src='/personal-blog/img/404.jpg'" alt="MySQL"></a></div><div class="recent-post-info"><a class="article-title" href="/personal-blog/2022/07/13/MySQL/" title="MySQL">MySQL</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-07-13T09:38:00.957Z" title="Created 2022-07-13 17:38:00">2022-07-13</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/personal-blog/categories/MySQL/">MySQL</a></span></div><div class="content">
本文介绍了MySQL的基本知识点，收录了SQL学习和练习网站，收录了学习MySQL过程中常见的问题及解决办法


MySQL学习教程
菜鸟教程

老杜带你学_mysql入门基础

MySQL官方参考手册

牛客在线练习

leetcode在线练习


MySQL常见问题乱码问题
查看字符编码1mysql&gt;show variables like &quot;character%&quot;;
设置字符编码12345msyql&gt;set character_set_client  = utf8;msyql&gt;set character_set_connection  = utf8;msyql&gt;set character_set_database  = utf8;msyql&gt;set character_set_results  = utf8;msyql&gt;set character_set_server  = utf8;

注：这种方式设置的字符编码是临时的，MySQL重启后字符编码会恢复为默认值。



如果设置了字符编码存入数据库时还是乱码，则使用1mys ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/personal-blog/2022/07/13/JAVA/" title="JAVA"><img class="post_bg" src="https://gitee.com/DreamcatcherDENG/drawing-bed/raw/master/img/wallhaven-72rd8e.jpg" onerror="this.onerror=null;this.src='/personal-blog/img/404.jpg'" alt="JAVA"></a></div><div class="recent-post-info"><a class="article-title" href="/personal-blog/2022/07/13/JAVA/" title="JAVA">JAVA</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-07-13T09:38:00.948Z" title="Created 2022-07-13 17:38:00">2022-07-13</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/personal-blog/categories/Java/">Java</a></span></div><div class="content">
文档描述

 
学习资源书籍：

《Head First Java》
《Java 8实战》
《Effective Java》

视频：

java 8 

java


代码：

java 8代码片段

项目：


Java简介JAVA环境
JRE (Java Runtime Environment)要运行一个java程序只需要 jre 即可
JDK (Java Development Environment)jdk 包含了编译工具javac.exe和运行工具java.exe


JAVA语言特点
面向对象Java语言的设计集中于对象及其接口 ,它提供了简单的类机制以及动态的接口模型。对象中封装了它的状态变量以及相应的方法 ,实现了模块化和信息隐藏 ;而类则提供了一类对象的原型 ,并且通过继承机制 ,子类可以使用父类所提供的方法 ,实现了代码的复用。

分布性Java是面向网络的语言。通过它提供的类库可以处理 TCP/IP协议 ,用户可以通过URL地址在网络上很方便地访问其它对象。

简单性Java语言是一种面向对象的语言 ,它通过提供最基本的方法来完成指定的任务 ,只需理解一些基本 ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/personal-blog/2022/07/13/ViewPager/" title="ViewPager"><img class="post_bg" src="https://gitee.com/DreamcatcherDENG/drawing-bed/raw/master/img/wallhaven-0qxx54.jpg" onerror="this.onerror=null;this.src='/personal-blog/img/404.jpg'" alt="ViewPager"></a></div><div class="recent-post-info"><a class="article-title" href="/personal-blog/2022/07/13/ViewPager/" title="ViewPager">ViewPager</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-07-13T09:38:00.929Z" title="Created 2022-07-13 17:38:00">2022-07-13</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/personal-blog/categories/Android/">Android</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/personal-blog/categories/Android/Android-%E6%8E%A7%E4%BB%B6/">Android 控件</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/personal-blog/categories/%E6%95%88%E6%9E%9C/">效果</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/personal-blog/categories/%E6%95%88%E6%9E%9C/ViewPager%E5%AE%9E%E7%8E%B0%E7%BF%BB%E9%A1%B5%E6%95%88%E6%9E%9C/">ViewPager实现翻页效果</a></span></div><div class="content">
1.ViewPager实现翻页效果
2.使用ViewPager2实现滑动翻页效果


ViewPager实现翻页效果布局资源代码activity_main.xml
123456789101112131415&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;    xmlns:tools=&quot;http://schemas.android.com/tools&quot;    android:layout_width=&quot;match_parent&quot;    android:layout_height=&quot;match_parent&quot;    tools:context=&quot ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/personal-blog/2022/07/13/ToolBar/" title="ToolBar"><img class="post_bg" src="https://gitee.com/DreamcatcherDENG/drawing-bed/raw/master/img/wallhaven-0qxx54.jpg" onerror="this.onerror=null;this.src='/personal-blog/img/404.jpg'" alt="ToolBar"></a></div><div class="recent-post-info"><a class="article-title" href="/personal-blog/2022/07/13/ToolBar/" title="ToolBar">ToolBar</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-07-13T09:38:00.926Z" title="Created 2022-07-13 17:38:00">2022-07-13</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/personal-blog/categories/Android/">Android</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/personal-blog/categories/Android/Android-%E6%8E%A7%E4%BB%B6/">Android 控件</a></span></div><div class="content">


ToolBar常见属性设置
设置navigationIcon可被点击
设置ToolBar的Title居中


ToolBar常见属性设置



属性
说明




android:background
背景


app:title
标题


app:subtitle
子标题


app:titleTextColor
颜色


app:subtitleTextColor
子标题颜色


app:titleMarginStart
标题距离左边开始的间距(有Icon相对于Icon,无Icon相对于父容器边界)


app:navigationIcon
导航图标


app:logo




12345678910111213&lt;androidx.appcompat.widget.Toolbar        android:id=&quot;@+id/toolbar1&quot;        android:layout_width=&quot;match_parent&quot;        android:layout_height=&quot;?attr/actionBa ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/personal-blog/2022/07/13/TextView/" title="TextView"><img class="post_bg" src="https://gitee.com/DreamcatcherDENG/drawing-bed/raw/master/img/romance-2258599_960_720.jpg" onerror="this.onerror=null;this.src='/personal-blog/img/404.jpg'" alt="TextView"></a></div><div class="recent-post-info"><a class="article-title" href="/personal-blog/2022/07/13/TextView/" title="TextView">TextView</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-07-13T09:38:00.924Z" title="Created 2022-07-13 17:38:00">2022-07-13</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/personal-blog/categories/Android/">Android</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/personal-blog/categories/Android/Android-%E6%8E%A7%E4%BB%B6/">Android 控件</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/personal-blog/categories/%E6%95%88%E6%9E%9C/">效果</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/personal-blog/categories/%E6%95%88%E6%9E%9C/%E6%96%87%E5%AD%97%E9%98%B4%E5%BD%B1/">文字阴影</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/personal-blog/categories/%E6%95%88%E6%9E%9C/%E8%B7%91%E9%A9%AC%E7%81%AF/">跑马灯</a></span></div><div class="content">
1.运行第一个android应用
2.实现文字带阴影
2.实现文字跑马灯


第一个Android应用创建Project下载并配置完Android Studio,选择New Project -&gt; 选择Empty Activity-&gt;next,等待项目构建



配置模拟器下载模拟器模拟器随便选能用就行

启动模拟器
第一个安卓应用
效果展示
项目结构介绍
TextView常用属性



字段
解释




layout_width
控件的宽度单位 dp 可选值:fill_parent、match_parent(和匹配父容器),wrap_content（包裹内容）


layout_height
控件的高度dp，（同layout_width）


id
控件的id，用于区别其他组件


text
控件中文本显示的内容


textColor
文本字体颜色


textStyle
可选风格:normal(无效果)，bold(加粗)，italic(斜体)


textSize
文本字体大小单位sp,


background
控件背景色（可以是图片）


gravity
内容的 ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/personal-blog/2022/07/13/TableLayout/" title="TableLayout"><img class="post_bg" src="https://gitee.com/DreamcatcherDENG/drawing-bed/raw/master/img/wallhaven-72rd8e.jpg" onerror="this.onerror=null;this.src='/personal-blog/img/404.jpg'" alt="TableLayout"></a></div><div class="recent-post-info"><a class="article-title" href="/personal-blog/2022/07/13/TableLayout/" title="TableLayout">TableLayout</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-07-13T09:38:00.918Z" title="Created 2022-07-13 17:38:00">2022-07-13</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/personal-blog/categories/Android/">Android</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/personal-blog/categories/Android/Android-%E5%B8%83%E5%B1%80/">Android 布局</a></span></div><div class="content">
1.TableLayout属性
2.TableLayout布局


TableLayout属性对于父控件



属性
说明




collapseColumns
隐藏该列（可以是多列）


shrinkColumns
收缩该列（可以是多列）


stretchColumns
拉伸该列（可以是多列）




对于子控件



属性
说明









TableLayout布局正常123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;TableLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;    xmlns:tools=&quot;http://schemas.android.com/tools&quot;     ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/personal-blog/2022/07/13/SimulateActivity/" title="模拟Android的点击事件"><img class="post_bg" src="https://gitee.com/DreamcatcherDENG/drawing-bed/raw/master/img/wallhaven-eopr6l-165133056464911.jpg" onerror="this.onerror=null;this.src='/personal-blog/img/404.jpg'" alt="模拟Android的点击事件"></a></div><div class="recent-post-info"><a class="article-title" href="/personal-blog/2022/07/13/SimulateActivity/" title="模拟Android的点击事件">模拟Android的点击事件</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-07-13T09:38:00.915Z" title="Created 2022-07-13 17:38:00">2022-07-13</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/personal-blog/categories/Android/">Android</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/personal-blog/categories/Android/%E5%AD%A6%E4%B9%A0%E6%84%9F%E6%82%9F/">学习感悟</a></span></div><div class="content">

定义View类
定义View的子类，TextView和孙子类Button
编写layout.xml文件和manifest.xml文件
定义布局资源加载器类
定义抽象类Activity
重写抽象类中的方法
定义Manifest加载加载器类



模拟Android点击事件定义View类123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111public class View &#123;    /**     * 点击事件监听器     */    ClickListener clickListener;    /**     * 是否可以点击     */    private boolean  ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/personal-blog/2022/07/13/Room/" title="Room"><img class="post_bg" src="https://gitee.com/DreamcatcherDENG/drawing-bed/raw/master/img/wallhaven-eopr6l-165133056464911.jpg" onerror="this.onerror=null;this.src='/personal-blog/img/404.jpg'" alt="Room"></a></div><div class="recent-post-info"><a class="article-title" href="/personal-blog/2022/07/13/Room/" title="Room">Room</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-07-13T09:38:00.913Z" title="Created 2022-07-13 17:38:00">2022-07-13</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/personal-blog/categories/Android/">Android</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/personal-blog/categories/Android/Jetpack/">Jetpack</a></span></div><div class="content">

Room的使用



Room的使用定义实体
Entity
一个实体对应于数据库中的一张表，使用Entity注解将Java中的类与数据库中的表绑定

tableName
Entity注解中的参数tableName默认值与类名相同

primaryKeys
参数primaryKeys可以指定该实体中的主键




1234@Entity(tableName = &quot;student&quot;,primaryKeys=&#123;&quot;id&quot;,&quot;name&quot;&#125;,)public class Student &#123;    ...&#125;

ignoredColumns
参数ignoredColumns可以指定需要忽略的属性，被忽略的属性将不会与实体中的字段相对应，但仍然可以在Java代码中使用



PrimaryKey
标记该属性是否为主键

autoGenerate为true设置为自动增长，默认为不自动增长
12@PrimaryKey(autoGenerate = true)public int id;



ColumnI ...</div></div></div><nav id="pagination"><div class="pagination"><span class="page-number current">1</span><a class="page-number" href="/personal-blog/page/2/#content-inner">2</a><span class="space">&hellip;</span><a class="page-number" href="/personal-blog/page/4/#content-inner">4</a><a class="extend next" rel="next" href="/personal-blog/page/2/#content-inner"><i class="fas fa-chevron-right fa-fw"></i></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://n.sinaimg.cn/sinakd10100/452/w1080h972/20200416/93dc-iskepxs3894040.jpg" onerror="this.onerror=null;this.src='/personal-blog/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">dreamcatcherdeng</div><div class="author-info__description"></div></div><div class="card-info-data is-center"><div class="card-info-data-item"><a href="/personal-blog/archives/"><div class="headline">Articles</div><div class="length-num">34</div></a></div><div class="card-info-data-item"><a href="/personal-blog/tags/"><div class="headline">Tags</div><div class="length-num">0</div></a></div><div class="card-info-data-item"><a href="/personal-blog/categories/"><div class="headline">Categories</div><div class="length-num">35</div></a></div></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/DreamcatcherDENG" target="_blank" title="Github"><i class="fab fa-github"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>Announcement</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>Recent Post</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/personal-blog/2022/07/13/RegularExpression/" title="正则表达式"><img src="https://gitee.com/DreamcatcherDENG/drawing-bed/raw/master/img/romance-2258599_960_720.jpg" onerror="this.onerror=null;this.src='/personal-blog/img/404.jpg'" alt="正则表达式"/></a><div class="content"><a class="title" href="/personal-blog/2022/07/13/RegularExpression/" title="正则表达式">正则表达式</a><time datetime="2022-07-13T09:38:01.002Z" title="Created 2022-07-13 17:38:01">2022-07-13</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/personal-blog/2022/07/13/Nodejs/" title="JavaScript and NodeJs"><img src="https://gitee.com/DreamcatcherDENG/drawing-bed/raw/master/img/wallhaven-0qxx54.jpg" onerror="this.onerror=null;this.src='/personal-blog/img/404.jpg'" alt="JavaScript and NodeJs"/></a><div class="content"><a class="title" href="/personal-blog/2022/07/13/Nodejs/" title="JavaScript and NodeJs">JavaScript and NodeJs</a><time datetime="2022-07-13T09:38:00.960Z" title="Created 2022-07-13 17:38:00">2022-07-13</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/personal-blog/2022/07/13/MySQL/" title="MySQL"><img src="https://gitee.com/DreamcatcherDENG/drawing-bed/raw/master/img/wallhaven-e7ek7k.jpg" onerror="this.onerror=null;this.src='/personal-blog/img/404.jpg'" alt="MySQL"/></a><div class="content"><a class="title" href="/personal-blog/2022/07/13/MySQL/" title="MySQL">MySQL</a><time datetime="2022-07-13T09:38:00.957Z" title="Created 2022-07-13 17:38:00">2022-07-13</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/personal-blog/2022/07/13/JAVA/" title="JAVA"><img src="https://gitee.com/DreamcatcherDENG/drawing-bed/raw/master/img/wallhaven-72rd8e.jpg" onerror="this.onerror=null;this.src='/personal-blog/img/404.jpg'" alt="JAVA"/></a><div class="content"><a class="title" href="/personal-blog/2022/07/13/JAVA/" title="JAVA">JAVA</a><time datetime="2022-07-13T09:38:00.948Z" title="Created 2022-07-13 17:38:00">2022-07-13</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/personal-blog/2022/07/13/ViewPager/" title="ViewPager"><img src="https://gitee.com/DreamcatcherDENG/drawing-bed/raw/master/img/wallhaven-0qxx54.jpg" onerror="this.onerror=null;this.src='/personal-blog/img/404.jpg'" alt="ViewPager"/></a><div class="content"><a class="title" href="/personal-blog/2022/07/13/ViewPager/" title="ViewPager">ViewPager</a><time datetime="2022-07-13T09:38:00.929Z" title="Created 2022-07-13 17:38:00">2022-07-13</time></div></div></div></div><div class="card-widget card-categories"><div class="item-headline">
            <i class="fas fa-folder-open"></i>
            <span>Categories</span>
            <a class="card-more-btn" href="/personal-blog/categories/" title="More">
    <i class="fas fa-angle-right"></i></a>
            </div>
            <ul class="card-category-list" id="aside-cat-list">
            <li class="card-category-list-item "><a class="card-category-list-link" href="/personal-blog/categories/Android/"><span class="card-category-list-name">Android</span><span class="card-category-list-count">26</span></a><ul class="card-category-list child"><li class="card-category-list-item "><a class="card-category-list-link" href="/personal-blog/categories/Android/Android-%E5%8A%A8%E7%94%BB/"><span class="card-category-list-name">Android 动画</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/personal-blog/categories/Android/Android-%E5%B8%83%E5%B1%80/"><span class="card-category-list-name">Android 布局</span><span class="card-category-list-count">6</span></a><ul class="card-category-list child"><li class="card-category-list-item "><a class="card-category-list-link" href="/personal-blog/categories/Android/Android-%E5%B8%83%E5%B1%80/layout-weight/"><span class="card-category-list-name">layout_weight</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/personal-blog/categories/Android/Android-%E5%B8%83%E5%B1%80/margin/"><span class="card-category-list-name">margin</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/personal-blog/categories/Android/Android-%E5%B8%83%E5%B1%80/padding/"><span class="card-category-list-name">padding</span><span class="card-category-list-count">1</span></a></li></ul></li><li class="card-category-list-item "><a class="card-category-list-link" href="/personal-blog/categories/Android/Android-%E6%8E%A7%E4%BB%B6/"><span class="card-category-list-name">Android 控件</span><span class="card-category-list-count">12</span></a><ul class="card-category-list child"><li class="card-category-list-item "><a class="card-category-list-link" href="/personal-blog/categories/Android/Android-%E6%8E%A7%E4%BB%B6/%E5%9B%BE%E7%89%87%E6%8B%89%E4%BC%B8%E5%8F%8A%E5%A1%AB%E5%85%85/"><span class="card-category-list-name">图片拉伸及填充</span><span class="card-category-list-count">1</span></a></li></ul></li></ul></li>
            </ul></div><div class="card-widget card-archives"><div class="item-headline"><i class="fas fa-archive"></i><span>Archives</span></div><ul class="card-archive-list"><li class="card-archive-list-item"><a class="card-archive-list-link" href="/personal-blog/archives/2022/07/"><span class="card-archive-list-date">July 2022</span><span class="card-archive-list-count">34</span></a></li></ul></div><div class="card-widget card-webinfo"><div class="item-headline"><i class="fas fa-chart-line"></i><span>Info</span></div><div class="webinfo"><div class="webinfo-item"><div class="item-name">Article :</div><div class="item-count">34</div></div><div class="webinfo-item"><div class="item-name">Total Count :</div><div class="item-count">54.9k</div></div><div class="webinfo-item"><div class="item-name">UV :</div><div class="item-count" id="busuanzi_value_site_uv"></div></div><div class="webinfo-item"><div class="item-name">PV :</div><div class="item-count" id="busuanzi_value_site_pv"></div></div><div class="webinfo-item"><div class="item-name">Last Push :</div><div class="item-count" id="last-push-date" data-lastPushDate="2022-07-16T16:42:17.888Z"></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2022 By dreamcatcherdeng</div><div class="framework-info"><span>Framework </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>Theme </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="darkmode" type="button" title="Toggle Between Light And Dark Mode"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="Toggle between single-column and double-column"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="Setting"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="Back To Top"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">Local search</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  Loading the Database</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="Search for Posts" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="/personal-blog/js/utils.js"></script><script src="/personal-blog/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js"></script><script src="/personal-blog/js/search/local-search.js"></script><div class="js-pjax"></div><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><script src="/personal-blog/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginModelPath":"assets/","model":{"jsonPath":"/personal-blog/live2dw/assets/shizuku.model.json"},"display":{"position":"left","width":250,"height":300,"hOffset":0,"vOffset":0,"opacity":0.1},"mobile":{"show":false},"log":false,"pluginJsPath":"lib/","pluginRootPath":"live2dw/","tagMode":false});</script></body></html>